#include <algorithm>

#include "Operator.h"

Operator::Operator(std::string n) :
	name(n), properties(EMPTY)
{
}

OperatorProperties Operator::getOpProperties()
{
	return properties;
}

std::string Operator::getName()
{
	return name;
}

void Operator::addCommOps(std::vector <Operator *> &ops)
{
	while (!ops.empty())
	{
		opsComm.push_back(ops.back());
		ops.pop_back();
	}
}

void Operator::setOpProperties(OperatorProperties properties)
{
	this->properties = OperatorProperties(this->properties | properties);
}

Operator *Operator::findCommOp(Operator *op)
{
	std::vector <Operator *> :: iterator it = std::find(opsComm.begin(), opsComm.end(), op);

	if (it != opsComm.end())
	{
		return *it;
	}

	return 0;
}

OperatorNode::OperatorNode(Operator *oper, Cost *c)
	: op(oper), cost(c)
{
}

OperatorNode::~OperatorNode()
{
	delete cost;	
}

